package webdev.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.preference.PreferenceManager;

public class StoreSharePreferences {

	/**
	 * 
	 * @decription:
	 * @author: Truong.Le
	 * @datetime: Nov 14, 2013 11:21:53 AM
	 * @param
	 */
	Context mContext;
	SharedPreferences sharedPreferences;
	public StoreSharePreferences(Context context) {
		this.mContext = context;
	}
	public boolean loadBooleandSavedPreferences(String keyValue) {
		sharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
		boolean value = sharedPreferences.getBoolean(keyValue, false);
		return value;
	}
	public String loadStringSavedPreferences(String keyValue) {
		sharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
		String value = sharedPreferences.getString(keyValue, "");
		return value;
	}
	public int loadIntegerSavedPreferences(String keyValue) {
		sharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
		int value = sharedPreferences.getInt(keyValue, 0);
		return value;
	}
	public float loadFloatSavedPreferences(String keyValue) {
		sharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
		float value = sharedPreferences.getFloat(keyValue, 0);
		return value;
	}
	public void savePreferences(String key, boolean value) {
		SharedPreferences sharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
		Editor editor = sharedPreferences.edit();
		editor.putBoolean(key, value);
		editor.commit();
	}

	public void savePreferences(String key, String value) {
		SharedPreferences sharedPreferences = PreferenceManager
				.getDefaultSharedPreferences(mContext);
		Editor editor = sharedPreferences.edit();
		editor.putString(key, value);
		editor.commit();
	}

}
